using System;
using System.Collections.Generic;
using Assets;
using HarmonyLib;
using PegasusLettuce;

namespace Mercenary
{
    //UI元素
    public class UiItem
    {
        public readonly int m_id;
        public readonly string m_name;

        public UiItem(int id, string name)
        {
            m_id = id;
            m_name = name;
        }
    }

    //佣兵技能
    public class MercSkill
    {
        public int m_id = -1;
        public string m_name;
        public int m_speed;
        public int m_damage;

        public MercSkill(int id, string name)
        {
             m_id = id;
             m_name = name;
        }
    }

    //佣兵装备
    public class MercEquip
    {
        public int m_id = -1;
        public string m_name;

        public MercEquip(int id, string name)
        {
             m_id = id;
             m_name = name;
        }
    }

    //佣兵英雄
    public enum TAG_ROLE
    {
        INVALID,
        CASTER,
        FIGHTER,
        TANK,
        NEUTRAL
    }
    public class MercCard
    {
        public int m_id = -1;
        public string m_name;
        public bool m_enable;
        public TAG_ROLE m_role;
        public int m_curHealth;
        public int m_defHealth;
        public int m_curSpeed;
        public int m_slotEquip;
        public List<MercSkill> m_skills;
        public List<MercEquip> m_equips;

        public MercCard() {}

        public MercCard(int id, string name)
        {
            m_id = id;
            m_name = name;
        }
    }

    /*
    public enum TargetType_E
    {
        Unspecified = 0,
        Friendly = 1
    }
    */

    /*
    public class BattleTarget
    {
        public int m_frieTarId = -1;
        public string m_frieTarName = "";
        public int m_oppoTarId = -1;
        public string m_oppoTarName = "";
        public int m_skillId = -1;
        public string m_skillName = "";
        public int m_subSkillId = -1;
        public string m_subSkillName = "";
        public TargetType_E m_targetType = TargetType_E.Unspecified;
        public bool m_bAllowOption = true;
    }
    */

    public class Map
    {
        public readonly int m_id;
        public readonly string m_name;
        public readonly string m_boss;

        public Map(int id)
        {
            m_id = id;
        }

        public Map(int id, string name)
        {
            m_id = id;
            m_name = name;
            m_boss = "";
        }

        public Map(int id, string name, string boss)
        {
            m_id = id;
            m_name = name;
            m_boss = boss;
        }
    }

    public enum TARGETTYPE
    {
        UNSPECIFIED = 0,
        FRIENDLY = 1
    }
    public class Skill
    {
        // Token: 0x0400000C RID: 12
        public int Id = -1;

        // Token: 0x0400000D RID: 13
        public string Name;

        // Token: 0x0400000E RID: 14
        public int Speed;
    }
    public class Target
    {
        public int Id = -1;
        public string Name;
        public int Attack;
        public int Health;
        public int Speed;
        public int DefHealth;
        public TAG_ROLE Role;
        public bool Enable;
        public List<Skill> Skills;
    }
    public class BattleTarget
    {
        public int TargetId = -1;
        public string TargetName = "";
        public int SkillId = -1;
        public string SkillName = "";
        public int SubSkillIndex = -1;
        public TARGETTYPE TargetType = TARGETTYPE.UNSPECIFIED;
        public string MercName = "";
        public bool NeedActive = true;
    }
    public interface IStrategy
    {
        List<BattleTarget> GetBattleTargets(
            int turn,
            List<Target> targets_opposite_all,
            List<Target> targets_friendly_all,
            List<Target> targets_opposite_graveyrad);
       (int hand_index, int play_index) GetEnterOrder(
           List<Target> hand_mercenaries,
           List<Target> play_mercenaries);
        string Name();
    }
    public class MercenaryEntity
    {
        public readonly int ID;
        public readonly string Skill;
        public readonly int Equipment;
        public readonly int SubSkillIndex = -1;
        public readonly TARGETTYPE TargetType = TARGETTYPE.UNSPECIFIED;
        public MercenaryEntity(int id)
        {
            this.ID = id;
        }
        public MercenaryEntity(int id, string skill, int eq = 0, int subskillindex = -1,
            TARGETTYPE targettype = TARGETTYPE.UNSPECIFIED)
        {
            this.ID = id;
            this.Skill = skill;
            this.Equipment = eq;
            this.SubSkillIndex = subskillindex;
            this.TargetType = targettype;
        }
    }

    /*
    public interface IStrategy
    {
        string Name();
        List<MercCard> GetMercList();
        void UpdateMercList();
        List<BattleTarget> GetBattleTargets(
            int turn,
            List<MercCard> targets_opposite_all,
            List<MercCard> targets_friendly_all,
            List<MercCard> targets_opposite_graveyrad);

        (int hand_index, int play_index) GetEnterOrder(
            List<MercCard> hand_mercenaries,
            List<MercCard> play_mercenaries);
    }
    */

    /*
    public class MercenaryEntity
	{
		public readonly int ID;
		public readonly string Skill;
		public readonly int Equipment;
		public readonly int SubSkillIndex = -1;
		public readonly TargetType_E TargetType = TargetType_E.Unspecified;

		public MercenaryEntity(int id)
		{
			ID = id;
		}

		public MercenaryEntity(int id, string skill, int eq = 0,int subskillindex = -1,
            TargetType_E targettype = TargetType_E.Unspecified)
		{
			ID = id;
			Skill = skill;
			Equipment = eq;
			SubSkillIndex = subskillindex;
			TargetType = targettype;
		}
	}
    */

    public class Task
    {
        public int water;//流水号，保证同优先级的任务是按照添加顺序排列的（长时间不重启可能会溢出）
        public int Id;// taskid
        public int Priority; // 优先级 小数优先级高
        public string Map;//1-1 h2-5 等
        public List<MercenaryEntity> Mercenaries = new List<MercenaryEntity>();// 佣兵以及佣兵技能选择列表
        public long StartAt;//任务进度起始时间
        public string ProgressMessage;//任务进度

        public Task()
        {
        }

        public Task(int id)
        {
            this.Mercenaries.Add(new MercenaryEntity(id));
        }
    }
}
